home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / graphics / gnuplot / term / iris4d.trm < prev    next >
Text File  |  1993-09-15  |  5KB  |  239 lines

  1. /*
  2.  * $Id: iris4d.trm%v 3.50 1993/07/09 05:35:24 woo Exp $
  3.  *
  4.  */
  5.  
  6. /* GNUPLOT - iris4d.trm */
  7. /*
  8.  * Copyright (C) 1990 - 1993   
  9.  *
  10.  * Permission to use, copy, and distribute this software and its
  11.  * documentation for any purpose with or without fee is hereby granted, 
  12.  * provided that the above copyright notice appear in all copies and 
  13.  * that both that copyright notice and this permission notice appear 
  14.  * in supporting documentation.
  15.  *
  16.  * Permission to modify the software is granted, but not the right to
  17.  * distribute the modified code.  Modifications are to be distributed 
  18.  * as patches to released version.
  19.  *  
  20.  * This software  is provided "as is" without express or implied warranty.
  21.  * 
  22.  * This file is included by ../term.c.
  23.  *
  24.  * This terminal driver supports:
  25.  *   IRIS terminals
  26.  *
  27.  * AUTHORS
  28.  *   John H. Merritt 
  29.  *           (Applied Research Corporation) 7/1/89
  30.  *           INTERNET: merritt@iris613.gsfc.nasa.gov
  31.  * 
  32.  * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
  33.  * 
  34.  */
  35.  
  36. #include <gl.h>
  37.  
  38. #define IRIS4DRC    ".gnuplot_iris4d"
  39.  
  40. #define IRIS4D_XMAX 1024
  41. #define IRIS4D_YMAX 1024
  42.  
  43. #define IRIS4D_XLAST (IRIS4D_XMAX - 1)
  44. #define IRIS4D_YLAST (IRIS4D_YMAX - 1)
  45.  
  46. #define IRIS4D_VCHAR (IRIS4D_YMAX/30)
  47. #define IRIS4D_HCHAR (IRIS4D_XMAX/72)
  48. #define IRIS4D_VTIC (IRIS4D_YMAX/80)
  49. #define IRIS4D_HTIC (IRIS4D_XMAX/80)
  50.  
  51. static short colors24bits[][3] =
  52. {
  53.     { 85,  85,  85  },  /* 0. BACK GROUND ( DARKGRAY ) */
  54.     { 0,   0,   0   },  /* 1. BLACK */
  55.     { 170, 0,   170 },  /* 2. MAGENTA */
  56.     { 85,  255, 255 },  /* 3. LIGHTCYAN */
  57.     { 170, 0,   0   },  /* 4. RED */
  58.     { 0,   170, 0   },  /* 5. GREEN */
  59.     { 255, 85,  255 },  /* 6. LIGHTMAGENTA */
  60.     { 255, 255, 85  },  /* 7. YELLOW */
  61.     { 255, 85,  85  },  /* 8. LIGHTRED */
  62.     { 85,  255, 85  },  /* 9. LIGHTGREEN */
  63.     { 0,   170, 170 },  /* 10. CYAN */
  64.     { 170, 170, 0   },  /* 11. BROWN */
  65. };
  66. #define COLOR24_SIZE (sizeof(colors24bits) / (sizeof(short) * 3))
  67.  
  68. static iris24bits = FALSE;
  69.  
  70. #define IRIS4D_BACKGROUND    0
  71. #define IRIS4D_BLACK        1
  72. #define IRIS4D_MAGENTA        2
  73. #define IRIS4D_LIGHTCYAN    3
  74. #define IRIS4D_RED        4
  75. #define IRIS4D_GREEN        5
  76. #define IRIS4D_LIGHTMAGENTA    6
  77. #define IRIS4D_YELLOW        7
  78. #define IRIS4D_LIGHTRED        8
  79. #define IRIS4D_LIGHTGREEN    9
  80. #define IRIS4D_CYAN        10
  81. #define IRIS4D_BROWN        11
  82.  
  83. IRIS4D_options()
  84. {
  85.   int i = 0;
  86.   struct value a;
  87.   extern struct value *const_express();
  88.   extern double real();
  89.  
  90.   if (!END_OF_COMMAND) {
  91.     i = (int) real(const_express(&a));
  92.   }
  93.  
  94.   iris24bits = (i == 24);
  95.  
  96.   sprintf(term_options, "%s",iris24bits ? "24" : "8");
  97. }
  98.  
  99. IRIS4D_init()
  100. {
  101.   int i;
  102.   char homedirfile[80], line[80];
  103.   FILE *f;
  104.  
  105.   foreground();
  106.   winopen("Gnuplot");
  107.   if (iris24bits)
  108.   {
  109.     RGBmode();
  110.     gconfig();
  111.   }
  112.  
  113.   strcat(strcat(strcpy(homedirfile,getenv("HOME")),"/"),IRIS4DRC);
  114.   if ((f = fopen(IRIS4DRC, "r")) != NULL ||
  115.       (f = fopen(homedirfile, "r")) != NULL) {
  116.     int c1, c2, c3;
  117.     for (i = 0; i < COLOR24_SIZE; i++) {
  118.       if (fgets(line, 79, f) == NULL ||
  119.       sscanf(line, "%d %d %d", &c1, &c2, &c3) != 3)
  120.     int_error("Iris4d color file terminated prematurely or wrong format.\n", NO_CARET);
  121.       colors24bits[i][0] = c1;
  122.       colors24bits[i][1] = c2;
  123.       colors24bits[i][2] = c3;
  124.     }
  125.       
  126.     fclose(f);
  127.   }
  128.   deflinestyle(1, 0x3FFF); /* long dash */
  129.   deflinestyle(2, 0x5555); /* dotted */
  130.   deflinestyle(3, 0x3333); /* short dash */
  131.   deflinestyle(4, 0xB5AD); /* dotdashed */
  132.   deflinestyle(5, 0x0F0F); /* dashed */
  133.   deflinestyle(6, 0xBBBB); /* dotdashed */
  134.   deflinestyle(7, 0x3F3F); /* mid-long dash */
  135.   deflinestyle(8, 0x7777); /* mid-long dash */
  136.  
  137.   return;
  138. }
  139.  
  140. IRIS4D_graphics()
  141. {
  142.   reshapeviewport();
  143.   ortho2((Coord)0, (Coord)IRIS4D_XMAX, (Coord)0, (Coord)IRIS4D_YMAX);
  144.   if (iris24bits)
  145.     RGBcolor(colors24bits[IRIS4D_BACKGROUND][0],
  146.          colors24bits[IRIS4D_BACKGROUND][1],
  147.          colors24bits[IRIS4D_BACKGROUND][2]);
  148.   else
  149.     color(WHITE);
  150.  
  151.   clear();
  152.   
  153.   return;
  154. }
  155.  
  156. IRIS4D_text()
  157. {
  158.   gflush(); /* flush buffer */
  159.   return; /* enter text from another window!!! */
  160. }
  161.  
  162. IRIS4D_linetype(linetype)
  163. int linetype;
  164. {
  165.   static int pen_color_24[11] =
  166.     {
  167.       IRIS4D_BLACK,        /* reserved for border and numbers */
  168.       IRIS4D_MAGENTA,        /* reserved for axis traces */
  169.       IRIS4D_LIGHTCYAN,
  170.       IRIS4D_RED,
  171.       IRIS4D_GREEN,
  172.       IRIS4D_LIGHTMAGENTA,
  173.       IRIS4D_YELLOW,
  174.       IRIS4D_LIGHTRED,
  175.       IRIS4D_LIGHTGREEN,
  176.       IRIS4D_CYAN,
  177.       IRIS4D_BROWN,
  178.     };
  179.   static int pen_color[8] = {0 ,1, 4, 5, 6, 1, 2, 4};
  180.  
  181.   if (iris24bits)
  182.   {
  183.     int pencolor = pen_color_24[linetype < 0 ? linetype + 2 : linetype % 9 + 2];
  184.  
  185.     RGBcolor(colors24bits[pencolor][0],
  186.          colors24bits[pencolor][1],
  187.          colors24bits[pencolor][2]);
  188.     /* Make all lines solid (linestyle 0) upto to the ninth. If more than
  189.      * 9 colors are needed, start to use the different line styles (1 to 8).
  190.      */
  191.     setlinestyle(linetype < 9 ? 0 : (linetype + 2) % 8 + 1);
  192.   }
  193.   else
  194.   {
  195.     linetype = linetype % 8;
  196.     color((Colorindex) pen_color[linetype]);
  197.     setlinestyle(linetype);
  198.   }
  199.   return;
  200. }
  201.  
  202. IRIS4D_move(x, y)
  203. unsigned int x, y;
  204. {
  205.   move2i(x, y);
  206.   return;
  207. }
  208.  
  209. IRIS4D_cmove(x, y)
  210. unsigned int x, y;
  211. {
  212.   cmov2i(x, y);
  213.   return;
  214. }
  215.  
  216. IRIS4D_vector(x, y)
  217. unsigned x, y;
  218. {
  219.   draw2i(x, y);
  220.   return;
  221. }
  222.  
  223.  
  224. IRIS4D_put_text(x,y,str)
  225. int x, y;
  226. char *str;
  227. {
  228.   IRIS4D_cmove(x,y - IRIS4D_VCHAR/2);
  229.   charstr(str);
  230.   return;
  231. }
  232.  
  233.  
  234. IRIS4D_reset()
  235. {
  236.   return;
  237. }
  238.  
  239.